<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Event</title>
</head>

<body>
<form>
<input type="button" id="bt1" value="添加事件" onclick='cEvent()' />
<input type="button" id="bt2" value="删除事件" onclick='dEvent()' />
<input type="button" id="bt3" value="点我" />
</form>
</body>
</html>
<script language="javascript">
var ie=!+"\v1";
var oBt=document.getElementById('bt3');
function cEvent(){
	ie?oBt.attachEvent('onclick',change):oBt.addEventListener('click',change,false);
}
function dEvent(){
	ie?oBt.detachEvent('onclick',change):oBt.removeEventListener('click',change,false);
}
function change(){
	alert('ok!');
}

</script>